/**
 * Created by zp on 2016/10/3.
 */

define([],function(){
  'use strict';
  function ctrl($state,$http,$scope,$rootScope,$ionicLoading,$timeout){
    $rootScope.shadeDivHeight = $("ion-view")[0].clientHeight+"px";
    $scope.divSetTop = document.getElementsByClassName("login-mydiv")[0].offsetTop + 60 + "px";

    $scope.loginInfo = {
      'email':'',
      'password':''
    }

    $scope.goresetpassword = function(){
      $state.go("tab.reset-password");
    }

    $scope.login = function(){
      $ionicLoading.show();
      var url = 'https://cartgogogo.com/custom/api/mobile/user.php';
      var data = "method=login&email="+$scope.loginInfo.email+"&password="+$scope.loginInfo.password;
      var promise = request.postreq(url,data);
      promise.then(
        function(success){
          $ionicLoading.hide();
          if(success.success == 0){
            //alert(success.return_code);
          }
        },
        function(error){
          $ionicLoading.hide();
        })
      $timeout(function(){
        $ionicLoading.hide();
      },3000)
    }

  }
  ctrl.$inject = ['$state','$http','$scope','$rootScope','$ionicLoading','$timeout'];
  return ctrl;
})
